import { index, modelOptions, Prop, getModelForClass } from "@typegoose/typegoose";
import BaseEntity from '../common/base.entity';

@modelOptions({
  schemaOptions: {
    collection: 'sessions',
  }
})
@index({ "expires_in": 1 }, { expireAfterSeconds: 0 })
export class SessionEntity extends BaseEntity {
  @Prop()
  data?: any;

  @Prop()
  id!: string;

  @Prop()
  expires_in!: Date;

  @Prop()
  _maxAge?: number;
}

export const SessionModel = getModelForClass(SessionEntity);
